<?php
namespace App\Api\V1\Models;

use Illuminate\Database\Eloquent\Model;

class Order extends Model
{

    protected $table = 'order';
    public $timestamps = false;
    public function confirmOrderList()
    {
        $data=[
            
            // 'user_id'=>'2',
            'order_no'=>'2',
            // 'source'=>'12'
            // 'name'=>'六一快乐',
            // 'description'=>'活动描述',
            // 'guide'=>'//careyshop.cn',
            // 'type'=>'2',
            // 'money'=>'100',
            // 'quota'=>'1000',
            // 'category'=>'[1,2,3]',
            // 'exclude_category'=>'[5,6,7]',
            // 'level'=>'[]',
            // 'frequency'=>'1',
            // 'give_num'=>'2000',
            // 'give_begin_time'=>'2018-05-22  10:11:00',
            // 'give_end_time'=>'2018-06-05  00:00:00',
            // 'use_begin_time'=>'2018-06-01   00:00:00',
            // 'use_end_time'=>'2018-06-02  00:00:00',
            // 'status'=>'1',
            // 'is_invalid'=>'0'

        ];
        
        $this->order_no =$data['order_no'];
        // $this->user_id =$ds['user_id'];
        // $this->source =$ds['source'];
        // $this->name = $ds['name'];
        // $this->description = $ds['description'];
        // $this->guide= $ds['guide'];
        // $this->type = $ds['type'];
        // $this->quota = $ds['quota'];
        // $this->category= $ds['category'];
        // $this->exclude_category = $ds['exclude_category'];
        // $this->level= $ds['level'];
        // $this->frequency = $ds['frequency'];
        // $this->give_num= $ds['give_num'];
        // $this->give_begin_time = $ds['give_begin_time'];
        // $this->give_end_time= $ds['give_end_time'];
        // $this->use_begin_time = $ds['use_begin_time'];
        // $this->use_end_time= $ds['use_end_time'];
        // $this->status = $ds['status'];
        // $this->is_invalid = $ds['is_invalid'];
       if ($this->save()) {
            return $this->toArray();
        }
        return false;


      }

      public function getOrderItem(){
        //查询 
        // $data=[
        //     'order_id'=>'29'
        // ];

         $list= order::get();
         return $list;
        
        }

        //删除
        // 取消一个订单
        public function cancelOrderItem()
    {
        $res=order::where('order_id','28')->delete();
        if($res){
            return $this->toArray();

        }
        return false;
        
    }



        //修改
        public function setOrderItem(){
            $data = [
                'source'=>'1',
                // 'name'=>'嘻嘻哈哈',
                // 'phonetic'=>'xixihaha',
                // 'description'=>'',
                // 'logo'=>'',
                // 'url'=>'',
                // 'target'=>'_blank',
                // 'sort'=>'50',
                // 'status'=>'1',
            ];
           $res = order::where('order_id',26)->update($data);
           if($res){
               return $this->toArray();
           }
           return false;


        //    $upd=DB::table('order')->where('order_id',29)->update($data);

        }
        
          
          
      


    
    
    

}
